﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.Master" AutoEventWireup="true"
    CodeBehind="CalendarioRecursos.aspx.cs" Inherits="SistemaWeb.Paginas.CalendarioRecursos"
    ValidateRequest="false" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<asp:Content ContentPlaceHolderID="PageTitlePlaceHolder" ID="ContTitle" runat="server">
    Calendario de Recursos
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" ID="Contenedor" runat="server">
    <div>
        <table width="100%">
            <tr>
                <td>
                    <table>
                        <tr>
                            <td style="width: 50px">
                                Recurso:
                            </td>
                            <td>
                                <asp:DropDownList ID="cboRecurso" runat="server" Width="200">
                                </asp:DropDownList>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Periodo:
                            </td>
                            <td>
                                <asp:DropDownList ID="cboMes" runat="server" Width="98">
                                </asp:DropDownList>
                                <asp:DropDownList ID="cboAnio" runat="server" Width="98">
                                </asp:DropDownList>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right">
                                <br />
                                <input type="button" value="Generar Calendario" id="btnGenerar" />
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div id="div1">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="divChart">
                    </div>
                </td>
            </tr>
        </table>
    </div>

    <script type="text/javascript">
        $(document).ready(function()
        {
            $('#btnGenerar').click(function()
            {
                ajaxCall();
            })
        });

        function renderChart(xml)
        {
            var chart1 = new FusionCharts("../Charts/FCF_Gantt.swf", "ChId1", "1024", "450", "0", "0");
            chart1.setDataXML(xml);
            chart1.setTransparent(true);
            chart1.render("divChart");
        }

        function ajaxCall()
        {
            var params = new Object();
            params.idRH = $('#<%=cboRecurso.ClientID%> option:selected').val();
            params.mes = $('#<%=cboMes.ClientID%> option:selected').val();
            params.anio = $('#<%=cboAnio.ClientID%> option:selected').val();
            var params = JSON.stringify(params);

            $.ajax({
                type: "POST",
                url: "CalendarioRecursos.aspx/GenerateXml",
                data: params,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function(result)
                {
                    xml = result.d;
                    renderChart(xml);
                },
                error: function(XMLHttpRequest, textStatus, errorThrown)
                {
                    //HandleError(XMLHttpRequest, textStatus, errorThrown);
                }
            });
        }
    </script>

</asp:Content>
